﻿@model PublicModel
@{
    ViewBag.Title = "首页";
}
@section Styles{
}
<div class="container" style="margin-top:20px;min-height:500px;">
    <div class="row">
        <div class="col-md-3">
            <div class="panel panel-default">
                <div class="panel-body" style="border:1px solid #ccc;">
                    @Html.Partial("_UserNavigation", Model.User)
                </div>
            </div>
        </div>
        <div class="col-md-6">
            <div class="panel panel-default" id="sharePanel">
                <div class="panel-body" style="border:1px solid #ccc;">
                    <div class="heading"><i class="glyphicon glyphicon-share"></i> 发布分享</div>
                    @if (!User.Identity.IsAuthenticated)
                    {
                        <div class="text-center">
                            <p style="margin-top:10px;"><i class="glyphicon glyphicon-exclamation-sign text-danger"></i>您还未登录，请<a href="@Url.ToAction("Index", "Home")">登录</a>或<a href="@Url.ToAction("Index", "Home")">注册</a>！</p>
                        </div>
                    }
                    else
                    {
                        <textarea id="content" class="form-control textarea-control" rows="3" placeholder="您想发布点什么吗？"></textarea>
                        <div class="row" style="margin-top:10px;">
                            <div class="col-md-7">
                                <span id="btnImage" class="fa fa-image" style="color:#00f;cursor:pointer;margin-right:10px;"> 图片</span>
                                <span id="btnFile" class="fa fa-file" style="color:#00f;cursor:pointer;"> 附件</span>
                            </div>
                            <div class="col-md-5 text-right">
                                <input type="hidden" id="viewRange" name="viewRange" value="0" />
                                <button type="button" class="btn btn-primary pull-right" onclick="publishActivity()" style="padding:5px 20px;">发布</button>
                                <div class="dropdown pull-right">
                                    <div id="dLabel" style="margin:7px 8px 0 0;cursor:pointer;" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                        <span id="viewRangeText">所有人可见</span>
                                        <span class="caret"></span>
                                    </div>
                                    <ul class="dropdown-menu viewRange" aria-labelledby="dLabel">
                                        @foreach (var item in Model.ViewRanges)
                                        {
                                            <li onclick="setViewRange('@item.Code', '@item.Name')">@item.Name</li>
                                        }
                                    </ul>
                                </div>
                            </div>
                        </div>
                        <script type="text/javascript">
                            function setViewRange(id, text) {
                                $('#viewRange').val(id);
                                $('#viewRangeText').html(text);
                            }

                            function publishActivity() {
                                var viewRange = $.trim($('#viewRange').val());
                                var content = $.trim($('#content').val());
                                $.post('@Url.ToAjax(AjaxRequestType.Activity_AddActivity)', {
                                    param: JSON.stringify([viewRange,content])
                                }, function (data) {
                                    Message.handle(data, function () { location = location; });
                                });
                            }
                        </script>
                    }
                </div>
            </div>
            @Html.Partial("_ActivityCategory")
            @Html.Partial("_ActivityList", Model.Activities)
        </div>
        <div class="col-md-3">
            <div class="panel panel-default">
                <div class="panel-body" style="border:1px solid #ccc;">
                    @Html.Partial("_UserInfo", Model.User)
                </div>
            </div>
            <div class="panel panel-default">
                <div class="panel-body" style="padding:0;">
                    <ul class="nav nav-tabs tabs" style="border-bottom:1px solid #ccc;">
                        <li class="active"><a href="#hot" data-toggle="tab">最近访客</a></li>
                    </ul>
                    <div class="tab-content">
                        <div class="tab-pane active" id="hot">
                            @Html.Partial("_UserGallery", new UserGalleryModel(UserGalleryType.RecentVisitor, Model.User.Id))
                        </div>
                    </div>
                </div>
            </div>
            <div class="panel panel-default">
                <div class="panel-body" style="padding:0;">
                    <ul class="nav nav-tabs tabs" style="border-bottom:1px solid #ccc;">
                        <li class="active"><a href="#hot" data-toggle="tab">我的好友</a></li>
                    </ul>
                    <div class="tab-content">
                        <div class="tab-pane active" id="hot">
                            @Html.Partial("_UserGallery", new UserGalleryModel(UserGalleryType.FriendUser, Model.User.Id))
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
